<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>服装款式</title>
<%@ include file="/WEB-INF/views/include/head.jsp"%>
<script src="${ctxStatic}/js/jquery-1.9.1.min.js"></script>
<script src="${ctxStatic}/js/DateTimePicker.js"></script>
<script src="${ctxStatic}/js/layer.js"></script>
<script src="${ctxStatic}/js/style.js"></script>
<script src="${ctxStatic}/dateCalendar/WdatePicker.js"></script>
<link rel="stylesheet" href="${ctxStatic}/css/common_erp.css">
<link rel="stylesheet" href="${ctxStatic}/css/list.css">
<script>
	$(document).ready(function() {
		$("#groupId").select2();
		/* $("#operatingName").select2(); */
		$(window.parent.$('#dtBox1')).DateTimePicker({
			dateFormat : "yyyy-MM-dd HH:mm",
			parentElement : ".timeBox",
		});

	});

	$(function() {
		$(".tabBox ul li").each(
				function() {
					var index = $(this).index();

					$(".tabBox ul li").eq(0).addClass("active");

					$(this).click(
							function() {

								//alert(index);

								$(this).addClass("active").siblings()
										.removeClass("active");

								//$(".tabBoxSm > .tabSm").eq(index).stop(true).show().siblings().stop(true).hide();
								$("#ulSelected").val($(this).val());
								//searchListForm();
								var tableW = $(".tabBoxSm > .tabSm").eq(index)
										.find('.tableHead').width();
								var tabodyH = $(".tabBoxSm > .tabSm").eq(index)
										.find('.tableBody').height();
								var tableScrollH = $(".tabBoxSm > .tabSm").eq(
										index).find('.tableScroll').height();
								if (tabodyH > tableScrollH) {
									$(".tabBoxSm > .tabSm").eq(index).find(
											'.tableScroll').css('width',
											tableW + 18 + 'px')
								} else {
									$(".tabBoxSm > .tabSm").eq(index).find(
											'.tableScroll').css('width',
											'inherit')
								}

							})

				})

	})


	// 导出
	function exportExcel() {
		var sGroupId = $("#groupId").find("option:selected").val();
		if(sGroupId == ""){
			tipParent("请选择班组");
			return;
		}
		var sPersonName = $("#personName").val();
		//var sOperatingName = $("#operatingName").find("option:selected").val();
		var sDateStart = $("#dateStart").val();
		var sDateEnd = $("#dateEnd").val();
		$("#activity_pane").showLoading();
		$.post("${ctx}/produce/workticket/exportWorkticket?userGroupEntity.userGroupId=" + sGroupId
				+ "&groupName=" + sGroupId
				+ "&personName="+sPersonName
				/* + "&operatingPEntity.itemNameCn=" + sOperatingName */
				+ "&dateStart=" + sDateStart
				+ "&dateEnd=" + sDateEnd, "" ,function(result) {
			if (result == "true") {
				window.location.href="${ctx}/produce/workticket/makeExportFile?dateStart="+sDateStart+"&dateEnd="+sDateEnd;
			}else {
				tipParent(result.message);
			}
			$("#activity_pane").hideLoading();
		}, 'json');
	}
	//检索 
	function searchListForm() {
		var sGroupId = $("#groupId").find("option:selected").val();
		var sPersonName = $("#personName").val();
		/* var sOperatingName = $("#operatingName").find("option:selected").val(); */
		var sDateStart = $("#dateStart").val();
		var sDateEnd = $("#dateEnd").val();
		
		$("#activity_pane").showLoading();
		$.post("${ctx}/produce/workticket/searchList?userGroupEntity.userGroupId=" + sGroupId
				+"&personName="+sPersonName
				/* + "&operatingPEntity.itemNameCn=" + sOperatingName */
				+ "&dateStart=" + sDateStart
				+ "&dateEnd=" + sDateEnd, "" ,function(result) {
			var listHtml = result["produceWorkticket"];
			var pageHtml = result["page"];
			$("#listHtml").html(listHtml);
			$("#paging").html(pageHtml);
			$("#activity_pane").hideLoading();
		}, 'json');
	}

	//重置
	function clean() {
		$("#groupId").val("");
		$("#groupId").select2();
		$("#personName").val("");
		/* $("#operatingId").find("option:selected").val(""); */
		$("#dateStart").val("");
		$("#dateEnd").val("");
		searchListForm();
	}
	function popupDetail(userId){
		
		popup('1020px','584px','${ctx}/produce/workticket/showDetail?updateBy.id='+userId+'&dateStart='+$("#dateStart").val()+'&dateEnd='+$("#dateEnd").val());
	}
</script>

</head>
<body>
	<form id="searchForm">
		<div class="listArea" id="activity_pane">
			<div class="listBg">
				<div class="searchArea clearfix">
					<div class="searchLeft clearfix" >
						<div class="searchInp clearfix" >
							<!-- 班组名称  -->
							<p><spring:message code="produce_workticket_groupName" /></p>
							<div class="searchInp">
								<select name="userGroupEntity.userGroupId" id="groupId"
									style="width: 120px">
									<option value=""><spring:message
											code="order_please_choose" /></option>
									<c:forEach items="${groupList}"
										var="group">
										<option
											value="${group.userGroupEntity.userGroupId}">${group.userGroupEntity.groupName}</option>
									</c:forEach>
								</select>
							</div>
						</div>
						<div class="searchInp clearfix">
							<!-- 人员姓名  -->
							<p><spring:message code="produce_workticket_userName" /></p>
							<input class="w-styleNub" id="personName"
								name="personName" value="">
						</div>
						<%-- <div class="searchInp clearfix">
							<!-- 工序名称  -->
							<p>工序名称</p>
							<div class="searchInp">
								<select name="operatingPEntity.itemNameCn" id="operatingName"
									style="width: 180px">
									<option value=""><spring:message
											code="order_please_choose" /></option>
									<c:forEach items="${operatingList}"
										var="operating">
										<option
											value="${operating.operatingPEntity.itemNameCn}">${operating.operatingPEntity.itemNameCn}</option>
									</c:forEach>
								</select>
							</div>
						</div> --%>
						<div class="searchInp clearfix">
							<!-- 日期  -->
							<p>
								<spring:message code="produce_workticket_date" />
							</p>
							<div class="timeBox">
								<input type="text" class="laydate-icon"
									onclick="WdatePicker({el:this,dateFmt:'yyyy-MM-dd',onpicked:null})"
									id="dateStart" name="dateStart" style="width: 110px" value="${fns:getDate('yyyy-MM-dd') }">
								<p class="list">~</p>
								<input type="text" class="laydate-icon"
									onclick="WdatePicker({el:this,dateFmt:'yyyy-MM-dd',onpicked:null})"
									id="dateEnd" name="dateEnd" style="width: 110px" value="${fns:getDate('yyyy-MM-dd') }">
							</div>
						</div>
					</div>
					<div class="searchRight clearfix">
						<button type="button" class="btn-js"  onclick="exportExcel()">
							<spring:message code="importExcel_export"/>
						</button>
						<button type="button" onclick="searchListForm();">
							<spring:message code="commom_check" />
						</button>
						<button type="button" onclick="clean();">
							<spring:message code="common_reset" />
						</button>
					</div>
				</div>
				<div class="tableArea" >
					<div class="tableScrollSm tabSm" style="height: 720px;overflow: auto;width: 677px;" >
						<table cellpadding="0" class="tableHead">
							<thead>
								<tr>
									<th><p class="table-No">
											<spring:message code="common_no" />
										</p></th>
									<th><p class="width-200px"><spring:message code="produce_workticket_groupName" /></p></th>
									<th><p class="width-200px"><spring:message code="produce_workticket_userName" /></p></th>
									<th><p class="width-100px"><spring:message code="produce_workticket_number" /></p></th>
									<th><p class="width-100px"><spring:message code="produce_workticket_detail" /></p></th>
								</tr>
							</thead>
						</table>
						<table cellpadding="0" class="tableBody">
							<tbody id="listHtml">
							</tbody>
						</table>
					</div>
				</div>
			</div>
			<div id="paging"></div>
		</div>
	</form>
</body>
</html>
